home *** CD-ROM | disk | FTP | other *** search
- #include <windows.h>
-
- long FAR PASCAL WndProc (HWND hWnd, WORD iMessage, WORD wParam, LONG lParam);
- int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdParam, int nCmdShow)
- {
- static HWND hWnd;
- MSG Message;
- WNDCLASS WndClass;
-
- if (!hPrevInstance)
- {
- WndClass.cbClsExtra = 0;
- WndClass.cbWndExtra = 0;
- WndClass.hbrBackground = GetStockObject(WHITE_BRUSH);
- WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
- WndClass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
- WndClass.hInstance = hInstance;
- WndClass.lpfnWndProc = (WNDPROC)WndProc;
- WndClass.lpszClassName = "NOPAL";
- WndClass.lpszMenuName = NULL;
- WndClass.style = CS_HREDRAW | CS_VREDRAW;
-
- RegisterClass (&WndClass);
- }
-
- hWnd = CreateWindow ("NOPAL", "Color Example 1: NoPal",
- WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
- 0, CW_USEDEFAULT, 0, NULL, NULL,
- hInstance, NULL);
-
- ShowWindow (hWnd, nCmdShow);
- while (GetMessage (&Message, 0, 0, 0))
- {
- TranslateMessage(&Message);
- DispatchMessage(&Message);
- }
- return Message.wParam;
- }
-
- /************************************************/
- /* Window Procedure : WndProc */
- /************************************************/
- long FAR PASCAL WndProc (HWND hWnd, WORD iMessage, WORD wParam, LONG lParam)
- {
-
- /**** Device Context variables ****/
- HDC hDC;
-
- /**** Pens and brushes ****/
- LOGPEN lpBlue; // Logical outline pen.
- LOGBRUSH lbBlue; // Logical fill brush.
- static HPEN hBluePen, hOldPen; // Actual new and previous pens.
- static HBRUSH hBlueBrush, hOldBrush; // Actual new and previous brushes.
- PAINTSTRUCT PtStr; // Something used by the Begin/EndPaint routines.
-
- /**** General variables ****/
- short x; // Generic counter for loops.
- int curcolor; // Current color.
-
- switch (iMessage)
- {
- case WM_PAINT:
- lpBlue.lopnStyle = PS_SOLID;
- lpBlue.lopnWidth.x = 1;
- lpBlue.lopnWidth.y = 0; // Not used
-
- lbBlue.lbStyle = BS_SOLID;
- lbBlue.lbHatch = 0; // Ignored when BS_SOLID
-
- hDC = BeginPaint(hWnd, &PtStr);
- curcolor = 0;
- for (x=1, curcolor=0; x<640; x=x+16, curcolor = curcolor + 6)
- {
- //*** Reference our colors:
- lpBlue.lopnColor = RGB(0,0,curcolor);
- lbBlue.lbColor = RGB(0,0,curcolor);
-
- //*** Create outline pen and fill brush:
- hBluePen = CreatePenIndirect(&lpBlue);
- hBlueBrush = CreateBrushIndirect(&lbBlue);
-
- //*** Tell hDC to use new pen&brush:
- hOldPen = SelectObject (hDC, hBluePen);
- hOldBrush = SelectObject (hDC, hBlueBrush);
-
- //*** Draw a cute picture:
- RoundRect (hDC,x,100,x+16,200,10,10);
-
-
-
- //*** De-allocate the current pen and brush.
- SelectObject (hDC, hOldPen);
- SelectObject (hDC, hOldBrush);
- DeleteObject(hBluePen);
- DeleteObject(hBlueBrush);
- }
-
- EndPaint(hWnd, &PtStr); // Tell GDI we're done with device context.
- return (0);
-
- case WM_DESTROY:
- PostQuitMessage(0);
- return (0);
- default:
- return (DefWindowProc (hWnd, iMessage, wParam, lParam));
- }
- }
-
-
-